<?php

class AbstractController extends Controller {

	const PasswordHash = "C1sj89as23a!@#213";

	private int $_now = 0;

	/**
	 * 初始化方法
	 */
	public function init() {
		return true;
	}

	public function debug($v) {
		echo '<pre>';
		print_r($v);
		echo '</pre>';
		exit;
	}

	public function template($tpl, $var = null) {
		$this->_view->assign($var);
		$this->_view->Controller = &$this;
		$this->_view->display($tpl);
	}

	public function getURI($path) {
		return $_SERVER['SCRIPT_NAME'] . $path;
	}

	public function now() {
		if (!$this->_now) {
			$this->_now = time();
		}
		return $this->_now;
	}

	public function showMsg($msg, $jumpURL = '') {
		$extra['resType'] = 'tpl';
		$extra['tpl'] = 'common/message.phtml';
		$extra['jumpURL'] = $jumpURL;
		parent::showMessage($msg, 0, array(), $extra);
	}

	public function genPassword($v) {
		return md5(self::PasswordHash . $v);
	}
}
